#ifndef _MYDOUBLELINKLIST_H_
#define _MYDOUBLELINKLIST_H_

#define ElementType void*
struct Node 
{
    ElementType data;
    struct Node *prev;
    struct Node *next;
};

typedef struct DoubleLinkList
{
    struct Node* head;
    struct Node* tail;
    int len;
}DLList;

int  InitDLList(DLList *list);
struct Node* CreateNode(ElementType element);
void TravelDLL(DLList *list,void(*func)(ElementType));
void FreeDLinkLIst(DLList *list,void(*func)(ElementType));

void  InsertTail(DLList *list,ElementType element);
void  InsertHead(DLList *list,ElementType element);
void  InsertIndex(DLList *list,ElementType element,int index);

void  RemoveByIndex(DLList* list ,int index);
void  RemoveByElement(DLList* list,ElementType element);

int   FindFirstByElement(DLList* list,ElementType element);
int* FindByElement(DLList* list,ElementType element);
//int FindByIndex(DLList* list,int index);

void SetValueByIndex(DLList* list,int index,ElementType element);
void SetValueByElement(DLList *list, ElementType oldValue, ElementType newValue);

int GetLListLen(DLList* list);
#endif